package com.boot.security.server.dao.mffl;

import java.util.List;
import java.util.Map;

import com.boot.security.server.model.mffl.Vo.MffCashwithdrawalapplicationVo;
import org.apache.ibatis.annotations.*;

import com.boot.security.server.model.mffl.MffCashwithdrawalapplication;

@Mapper
public interface MffCashwithdrawalapplicationDao {

    MffCashwithdrawalapplicationVo getById(Long id);

    @Delete("delete from mff_cashwithdrawalapplication where id = #{id}")
    int delete(Long id);

    int update(MffCashwithdrawalapplication mffCashwithdrawalapplication);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into mff_cashwithdrawalapplication(userid, nowmoney, expenditure, surplus, state, reasonsforfailure, operator, createTime, updateTime, deleteTime, DeleteState, points,pointsmoney) values(#{userid}, #{nowmoney}, #{expenditure}, #{surplus}, #{state}, #{reasonsforfailure}, #{operator}, #{createTime}, #{updateTime}, #{deleteTime}, #{DeleteState}, #{points}, #{pointsmoney})")
    int save(MffCashwithdrawalapplication mffCashwithdrawalapplication);
    
    int count(@Param("params") Map<String, Object> params);
    List<MffCashwithdrawalapplication> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    @Select("SELECT * FROM mff_cashwithdrawalapplication t WHERE t.id = #{id} AND userid = #{userid} AND DeleteState = 1")
    MffCashwithdrawalapplication getByuser(@Param("id") Long id,@Param("userid") Integer userid);

    int countSystem(@Param("params") Map<String, Object> params);
    List<MffCashwithdrawalapplicationVo> listSystem(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    @Update("update mff_cashwithdrawalapplication set state=#{state},operator=#{operator},updateTime=now() where id = #{id} ")
    int updateState(@Param("state") int state, @Param("id") Long id,@Param("operator") Long systemId);
}
